﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DiagrammInternalStructure
{
    /// <summary>
    /// List of all posible modifications for a different types of fields
    /// </summary>
    public enum FieldModification
    {
        StaticField,
        VirtualField,
        OverrideField,
        /// <summary>
        /// Array
        /// </summary>
        MultipleField,
        /// <summary>
        /// "out" modificator for elements of function signature
        /// </summary>
        OutParameter,
        /// <summary>
        /// "ref" modificator for elements of function signature
        /// </summary>
        RefferenceParameter,
        /// <summary>
        /// Modificator for last element of function signature, that have default value
        /// </summary>
        HaveDefaultValue
    }

    public class FieldElement:AtomicInstance
    {
        private ClassElement m_type = null;
        protected List<FieldModification> m_modification = new List<FieldModification>();
        private ClassElement m_container = null;

        public FieldElement(ClassElement currentClass, ProtectionType protection, string name, ClassElement type):base(name, protection)
        {
            m_type = type;
            m_container = currentClass;
        }

        protected FieldElement()
        { }

        public ClassElement Type
        {
            get
            {
                return m_type;
            }
        }

        public bool Multiple
        {
            get
            {
                return m_modification.Contains(FieldModification.MultipleField);
            }
            set
            {
                if (!Multiple && value)
                {
                    m_modification.Add(FieldModification.MultipleField);
                }
                else if (Multiple && !value)
                {
                    m_modification.Remove(FieldModification.MultipleField);
                }
            }
        }

        public virtual bool AddModification(FieldModification mod)
        {
            if (m_modification.Contains(mod))
            {
                return false;
            }
            m_modification.Add(mod);
            return true;
        }

        public virtual bool RemoveModification(FieldModification mod)
        {
            if (m_modification.Contains(mod))
            {
                m_modification.Remove(mod);
                return true;
            }
            return false;
        }
    }
}
